package cfdt.common.system;

import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.beans.factory.annotation.Value;
import org.springframework.stereotype.Component;

@Component
public class ApplicationEnvironment {
    
    private final static Logger logger = LoggerFactory.getLogger(ApplicationEnvironment.class);

    public static String appName;
    
    public static String appVersion;

    @Value("${spring.application.name}")
    public void setAppName(String appName) {
        ApplicationEnvironment.appName = appName;
    }

    @Value("${version}")
    public void setAppVersion( String appVersion) {
        ApplicationEnvironment.appVersion = appVersion;
    }

    /**
     * 打印启动成功
     */
    public static void printStartSuccess() {
        System.out.println(appName + " " + appVersion + " Startup Successfully!");
        logger.info(appName + " " + appVersion + " Startup Successfully!");
    }

    /**
     * 打印启动失败
     */
    public static void printStartFailed() {
        System.out.println(appName + " " + appVersion + " Startup Failed!");
        logger.info(appName + " " + appVersion + " Startup Failed!");
    }

}
